<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/include/includeHeader.jsp"%>
<%@ page import="java.util.*,
                 com.kylin.common.util.*,
                 com.kylin.hibernate.*,
                 com.kylin.common.paginate.DisplayPage,
                 com.kylin.module.ad.orm.*" %>
<html:form action="/admin/ad/manageAD.do" method="post" >
<input type="hidden" name="CMD" value="searchAD">
<table width="600" border=1 cellspacing="0" cellpadding="0">
    <tr><td align="left" width="100">广告类型</td>
        <td>
		<select name="adtype">
		<option value=""></option>
<% 
        List list=BaseHibernateDAO.findAll(ADType.class,null);
        if(list != null)
        	for(int i=0;i<list.size();i++){
        	    ADType adtype=(ADType)list.get(i);
%>
			<option value="<%=adtype.getId() %>" 
			  <%if((adtype.getId()+"").equals(request.getParameter("adtype")) )
			  out.print("selected"); %>><%=adtype.getName() %></option>
<%
        	    
        	}
%>        
		</select>
		</td>
        <td align="left" width="100">广告名称</td>
        <td><html:text property="name"/></td>
    </tr>
    <tr><td align="left" >广告所属人</td>
        <td><html:text property="owner"/></td>
        <td align="left" >投放语言版本</td>
        <td><mytag:national name="language" language="zh_CN"
				dictName="<%=Constants.SYSLANGUAGE%>" />
		</td>
    </tr>
    <tr><td align="left" >链接</td>
         <td><html:text property="link"/></td>
         <td align="left" >到期时间</td>
         <td>
			<mytag:CalendarInput name="endtime" id="endtimeId" 
				imgId="endtime_img" size="10"/>
         </td>
    </tr>
    <tr><td  align="left" >说明文字</td>
        <td colspan=3 align="left"><html:text property="memo"  /></td>
    </tr>
    <tr><td colspan=2 align=center><input type="submit" value="查询"></td></tr>
</table>    
</html:form>
                 
<br>
		<b>广告列表</b>
<br>
<mytag:MyActionMsg />
<table class='pageTable' cellspacing='0' cellpadding='0'> 
     <tr>
        <td class='pageTitle'>名称(投放语言)</td>
        <td class='pageTitle'>所处类别(顺序)</td>
        <td class='pageTitle'>所属人</td>
        <td class='pageTitle'>链接</td>
        <td class='pageTitle'>说明文字</td>
        <td class='pageTitle'>展示次数</td>
        <td class='pageTitle'>状态</td>
        <td class='pageTitle'>操作</td>
      </tr>

    <%
     if(request.getAttribute(Constants.KEY_REQUEST_RESULT) instanceof DisplayPage){
         DisplayPage dispage = (DisplayPage)request.getAttribute(Constants.KEY_REQUEST_RESULT);
         List list = dispage.getList();
         for(int i=0;i<list.size();i++){
         	if(list.get(i) instanceof AD){
             AD ad = (AD)list.get(i);
	%>
		<tr  class='row<%=i%2 %>'>
	        <td class='pageTd'><%=ad.getName() %><br>(<%=ad.getLanguage() %>)</td> 
	        <td class='pageTd'><%=ad.getAdtype().getName() %><br><%=ad.getAdtype().getMark() %>
	        				(<%=ad.getOrdering() %>) </td> 
	        <td class='pageTd'><%=ad.getOwner() %> </td> 
	        <td class='pageTd'><%=ad.getLink() %> </td> 
	        <td class='pageTd'><%=ad.getMemo() %> </td> 
	        <td class='pageTd'><%=(ad.getHits()==null)?"0":ad.getHits()+"" %> </td> 
	        <td class='pageTd'><%=ad.getActive() %> </td> 
	        <td class='pageTd'><a href="/admin/ad/manageAD.do?CMD=editAD&id=<%=ad.getId() %>">编辑</a> </td> 
	    </tr>
	<%             
			}else{
System.out.println("list.get(i)="+list.get(i));
			}
         }
     }
    %>  
      
</table>